﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data;
using ForumLibrary.Data;

public partial class ProfileInfo : System.Web.UI.Page
{
    private string friendDeleting;
    private string viewingFriend;

    protected void Page_Load(object sender, EventArgs e)
    {
        HtmlGenericControl forum = (HtmlGenericControl)Page.Master.FindControl("Forum");
        forum.Attributes.Remove("class");

        HtmlGenericControl notifications = (HtmlGenericControl)Page.Master.FindControl("Notifications");
        forum.Attributes.Remove("class");

        HtmlGenericControl profileInfo = (HtmlGenericControl)Page.Master.FindControl("ProfileInfo");
        profileInfo.Attributes.Add("class", "active");
    }

    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        friendDeleting = e.Values["Username"].ToString();
    }
    protected void FriendsDS_Deleting(object sender, ObjectDataSourceMethodEventArgs e)
    {
        e.InputParameters["friendRemoving"] = Session["username"];
        e.InputParameters["friendRemoved"] = friendDeleting;
    }
    protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        viewingFriend = GridView1.Rows[e.NewSelectedIndex].Cells[1].Text;
        FriendsDetailsDS.SelectParameters["username"] = new Parameter("username", TypeCode.String, viewingFriend);
        FriendsDetailsDS.Select();
    }
    protected void SearchButton_Click(object sender, EventArgs e)
    {
        UsersDS.SelectParameters["searchedUser"] = new Parameter("searchedUser", TypeCode.String, TextBox1.Text);
        UsersDS.Select();
    }
    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
        UsersDS.SelectParameters["searchedUser"] = new Parameter("searchedUser", TypeCode.String, TextBox1.Text);
        UsersDS.Select();
    }
    protected void GridView2_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        string friendBeingAdded = GridView2.Rows[e.NewSelectedIndex].Cells[1].Text;
        FriendsDS.InsertParameters["friendAdding"] = new Parameter("friendAdding", TypeCode.String, Session["username"].ToString());
        FriendsDS.InsertParameters["friendAdded"] = new Parameter("friendAdded", TypeCode.String, friendBeingAdded);
        FriendsDS.Insert();
    }
}